import { JSEncrypt } from 'jsencrypt'

const publicKey =
  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDaqYwCrh2f7hipvKtun43Ch2U1TE+625CUyjSho82mfweD5HFQbtwmuiM1bfPhHWrJG2UGoeEI29XxlfuLP8PskmumxEkf/HVcIHtU10w+fdcwPVZ2qOoFWD9KjPEBAsISslGSqOnEW4ybgzz+DyAQaO7SDCDQotmx1VLUYBRwQQIDAQAB'

const encryptor = new JSEncrypt()
encryptor.setPublicKey(publicKey) // 设置公钥

// 加密
export function encrypt(txt) {
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  return encryptor.decrypt(txt) // 对数据进行解密
}
